package edu.suda.xsap.service.impl;

import edu.suda.xsap.dto.CardDto;
import edu.suda.xsap.dto.convert.CardConvert;
import edu.suda.xsap.mapper.CardMapper;
import edu.suda.xsap.service.CardService;
import edu.suda.xsapadminutils.common.Result;
import edu.suda.xsapadminvo.CardVO;
import org.mapstruct.AfterMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CardServiceImpl implements CardService {
    @Autowired
    private CardMapper cardMapper;
    @Autowired
    private CardConvert cardConvert;

    @Override
    public Result save(CardVO cardVO) {
        cardMapper.save(cardVO);
        return Result.success();
    }

    @Override
    public Result update(CardVO cardVO) {
        cardMapper.update(cardVO);
        return Result.success();
    }

    @Override
    public List<CardDto> findAll() {
        return cardConvert.toDtoList(cardMapper.findAll());
    }
}
